package com.alone.jpa.query.condition.impl;

import com.alone.jpa.query.condition.Condition;
import com.alone.jpa.query.condition.ConditionType;
import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @author Alone
 */
@Data
@AllArgsConstructor
public class SimpleCondition implements Condition {

    public static final SimpleCondition OR_CONDITION = new SimpleCondition(ConditionType.OR, null, null, false);

    /**
     * 条件类型
     */
    private ConditionType conditionType;

    /**
     * 数据库字段
     */
    private String column;

    /**
     * 字段比较的值
     */
    private Object value;

    /**
     * 字段比较
     */
    private boolean valueIsColumn;

    public static SimpleCondition of(ConditionType conditionType, String column, Object value) {
        return new SimpleCondition(conditionType, column, value, false);
    }

    public static SimpleCondition ofColumn(ConditionType conditionType, String column, String value) {
        return new SimpleCondition(conditionType, column, value, true);
    }

}
